"""
响应工具函数
"""
from flask import jsonify

def success_response(data=None, message="操作成功", code=200):
    """成功响应"""
    response = {
        "success": True,
        "message": message,
        "code": code
    }
    if data is not None:
        response["data"] = data
    return response, code

def error_response(message="操作失败", code=400, data=None):
    """错误响应"""
    response = {
        "success": False,
        "message": message,
        "code": code
    }
    if data is not None:
        response["data"] = data
    return response, code
